execute store result score #HP temp run data get entity @s item.components."minecraft:custom_data".guardTowerData.HP
$execute store result entity @s item.components."minecraft:custom_data".guardTowerData.HP int 1 run scoreboard players set #HP temp $(value)

execute store result score #maxHP temp run data get entity @s item.components."minecraft:custom_data".guardTowerData.maxHP
execute if score #HP temp >= #maxHp temp store result entity @s item.components."minecraft:custom_data".guardTowerData.HP int 1 run scoreboard players operation #HP temp = #maxHP temp

execute if score #HP temp matches ..0 run function vs:system/game_ctrol/guard_tower/break

execute as @n[tag=guardTower.healthDisplay,distance=..5,type=text_display] at @s run function vs:system/game_ctrol/guard_tower/health/update_display

scoreboard players reset #maxHP temp
scoreboard players reset #HP temp